package main

import "fmt"

func assign1(a interface{}) {
	fmt.Printf("%T\n", a)
	str, ok := a.(string)
	if !ok {
		fmt.Println("类型断言失败/出错")
	} else {
		fmt.Println("类型断言成功：是字符串")
	}
	fmt.Printf("%T\n", str)
}

func assign2(a interface{}) {
	fmt.Printf("%T\n", a)
	switch t := a.(type) {
	case string:
		fmt.Println("类型断言为字符串", t)
	case int:
		fmt.Println("类型断言为字符串", t)
	case int64:
		fmt.Println("类型断言为字符串", t)
	case bool:
		fmt.Println("类型断言为字符串", t)
	}
}

func main() {
	// assign1(11)
	assign2(11)
}
